1. Field of the Invention
The present invention relates to the field of XML documents and, more particularly, to a method, system, and computer-program product for providing selective access to certain child nodes of a Document Object Model (DOM).
2. Discussion of the Related Art
The use of Extensible Markup Language (XML) is very popular in the development of software applications. Originally XML was used primarily for the exchanging of data between two applications, but XML is now applied to almost every aspect of a software application where easy declaration of data structures and customization of data are required.
When an XML document is read and parsed, the output of the parsing process is a tree structure called a Document Object Model, otherwise known as a DOM tree. The DOM tree is simply a tree-like structure providing a visual representation of the hierarchy of an XML document, where each node of the tree represents an XML tag.
FIG. 1A is an example of a small section of XML text and FIG. 1B illustrates a DOM tree corresponding to the XML text of FIG. 1A.
When parsed, the XML text of FIG. 1A will result in the DOM tree of FIG. 1B. As can be seen, the DOM tree consists of several nodes: “Customer”; “Last-Name”; “First-Name”; “Address”; “Street”; “City”; “State”; and “Zipcode”, and each node may have “children”. For example, the node “Customer” is a parent node to three children: “Last-Name”, “First-Name”, and “Address”. Similarly, the node “Address” is a parent node to four children: “Street”, “City”, “State”, and “Zipcode”.
Each node typically is an instance of an object and there are executable methods that may be performed on each node. For example, if the method “getChildNodes( )” is called on the “Customer” node of FIG. 1A, a list is compiled containing the nodes (Last-Name, First-Name, and Address). A node may also have a text value, which may be retrieved using the method “getNodeValue( )”. Thus, if the “Street” node contains the value “8008 Greely Court”, then calling “getNodeValue( ) on the “Street” node will retrieve (8008 Greely Court).
The World Wide Web Consortium has developed a standard framework and API that defines access to the nodes of a DOM Tree (see http://www.w3c.org for further information and a complete discussion of the API and framework). The w3c DOM API allows the children to be searched, enumerated (to enable retrieval of contents, the formulation of lists of children, and the like), and in some high performance DOM implementations a child node may be looked up by the value of an attribute (which allows a program to access the contents of a DOM in any contextual manner).
Under the DOM standard of the prior art, there is no way to restrict access to certain of the child nodes while allowing access to others; it is an all-or-nothing proposition. Thus, under the DOM standard of the prior art, restricted access selectively among nodes (to allow, for example, limited access to nodes that have sensitive information or nodes that have contextual data which could only be accessed if the system is set to operate in that context) cannot be facilitated. Accordingly, it would be desirable to have a DOM in which the DOM nodes are enhanced to provide XOR access, that is, where the DOM nodes can be identified by a particular value and where only those nodes that match a selected one of these values will be “visible” at any point in time.